Some more fixed to prevent segfaults with missing or nonsensical ranges.
authorMatthias Clasen <mclasen@redhat.com>
Fri, 21 Sep 2007 15:38:29 +0000 (15:38 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 21 Sep 2007 15:38:29 +0000 (15:38 +0000)
2007-09-21  Matthias Clasen <mclasen@redhat.com>

        * gtk/gtkprintoperation.c (print_pages_idle): Some more
        fixed to prevent segfaults with missing or nonsensical ranges.

svn path=/trunk/; revision=18854

ChangeLog
gtk/gtkprintoperation.c

index 5132cb72bebd0c426419f0d5b3486255fc252e49..0fe14d327b478cfa8177d752a74faefd92d8967d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-21  Matthias Clasen <mclasen@redhat.com>
+
+       * gtk/gtkprintoperation.c (print_pages_idle): Some more
+       fixed to prevent segfaults with missing or nonsensical ranges.
+
 2007-09-21  Jean Brefort  <jean.brefort@normalesup.org>
 
        * gtk/gtkprintoperation.c: (print_pages_idle): abort printing 
index 1c3a1901f08043f37fa532a4438ad4a3387155b6..4519cd24fba5673412e4b4a2eff588a04b8c11dc 100644 (file)
@@ -2090,23 +2090,21 @@ print_pages_idle (gpointer user_data)
            goto out;
        }
 
-      /* FIXME handle this better */
-      if (priv->nr_of_pages == 0)
-       g_warning ("no pages to print");
-      
       /* Initialize parts of PrintPagesData that depend on nr_of_pages
        */
       if (priv->print_pages == GTK_PRINT_PAGES_RANGES)
        {
-         if (priv->page_ranges == NULL) {
-                 g_warning ("no pages to print");
-                 priv->cancelled = TRUE;
-                 goto out;
+          if (priv->page_ranges == NULL) 
+            {
+              g_warning ("no pages to print");
+              priv->cancelled = TRUE;
+              goto out;
          }
          data->ranges = priv->page_ranges;
          data->num_ranges = priv->num_page_ranges;
           for (i = 0; i < data->num_ranges; i++)
-            if (data->ranges[i].end == -1)
+            if (data->ranges[i].end == -1 || 
+                data->ranges[i].end >= priv->nr_of_pages)
               data->ranges[i].end = priv->nr_of_pages - 1;
        }
       else if (priv->print_pages == GTK_PRINT_PAGES_CURRENT &&